#include <unistd.h>
#include <sys/types.h> //包含pid_t的头文件
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
main(int argc, char const *argv[])
{
    pid_t pid;
    if ((pid = fork()) == 0)
    {
        int o_ret;
        o_ret = open("8000116092.txt", O_RDWR | O_CREAT | O_TRUNC, 0644);
        if (-1 == o_ret)
        {
            perror("file");
            exit(1);
        }
        dup2(o_ret, STDOUT_FILENO);
        execlp("date", "date", NULL);
        exit(0);
        printf("----------------1st child end------------------\n");
    }

    if ((pid = fork()) == 0)
    {
        printf("----------------2nd child start------------------\n");
        printf("child pid: %d\n", getpid());

        printf("----------------2nd child end------------------\n");
        exit(0);
    }
   
    return 0;
}
